package server;

import javax.servlet.Servlet;
import javax.servlet.ServletException;
import java.io.IOException;

public abstract class HttpServlet implements Servlet{

    public abstract void doGet(Request request, Response response);

    public abstract void doPost(Request request, Response response);

    public void service(Request request, Response response) throws ServletException, IOException {
        if("GET".equalsIgnoreCase(request.getMethod())){
            doGet(request, response);
        } else if("POST".equalsIgnoreCase(request.getMethod())){
            doPost(request, response);
        } else {
            doGet(request, response);
        }
    }
}
